package veterinaria.servlets;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import veterinaria.negocio.GestionPublicidad;
/**
 * Servlet implementation class PublicidadIngresoServlet
 */
@WebServlet("/PublicidadIngresoServlet")
public class PublicidadIngresoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PublicidadIngresoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String pTit = request.getParameter("txtTit");
		String pCon = request.getParameter("txtCon");
		String pFIn = request.getParameter("txtFIn");
		String pFFi = request.getParameter("txtFFi");
		String cTar = request.getParameter("txtTar");
		String cCli = request.getParameter("txtCli");
		String cUbi = request.getParameter("txtUbi");			
		Double pTar = Double.parseDouble(cTar);
		int pCli = Integer.parseInt(cCli);
		int pUbi = Integer.parseInt(cUbi);
		
 	    try {
	        GestionPublicidad negocio = new GestionPublicidad();
	        negocio.insertar(pTit, pCon, pFIn, pFFi, pTar, pCli, pUbi);
	        request.setAttribute("publicidads", negocio.listar());
	        RequestDispatcher rd = request.getRequestDispatcher("PublicidadListar.jsp");
	        rd.forward(request, response);
	    } catch (Exception e) {
	        System.out.println(e.getMessage());
	    }				
	}

}
